package com.tte.common.designpattern.factory;

import com.tte.common.designpattern.service.Shopping;
import com.tte.common.designpattern.service.impl.ShopCommputerImpl;
import com.tte.common.designpattern.service.impl.ShopFoodsImpl;
import com.tte.common.designpattern.service.impl.ShopPhoneImpl;

/**
 * 创建一个工厂，生成基于给定信息的实体类的对象
 */
public class ShoppingFactory {
    //使用 getShape 方法获取形状类型的对象
    public Shopping view(String shapeType){
        if(shapeType == null){
            return null;
        }
        if(shapeType.equalsIgnoreCase("phone")){
            return new ShopPhoneImpl();
        } else if(shapeType.equalsIgnoreCase("foods")){
            return new ShopFoodsImpl();
        } else if(shapeType.equalsIgnoreCase("commputer")){
            return new ShopCommputerImpl();
        }
        return null;
    }
}
